﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Gol.Domain;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Test.Gol.Domain.CellGrid
{
    [TestClass]
    public class BasicTests
    {
        [TestMethod]
        public void WhenCreatingCellGridThenCorrectlySizedCellGridShouldExist()
        {
            int rows = 20;
            int cols = 10;
            global::Gol.Domain.CellGrid grid = new global::Gol.Domain.CellGrid(rows, cols);
            Assert.IsTrue(grid.NumberOfRows == rows);
            Assert.IsTrue(grid.NumberOfColums == cols);

        }

        [TestMethod]
        public void WhenInitializingCellGridThenCorrectlyInitalizedShouldExist()
        {
            int rows = 20;
            int cols = 10;
            global::Gol.Domain.CellGrid grid = new global::Gol.Domain.CellGrid(rows, cols);
            grid.Intialize( new int[,]{{  0,  2 },  { 0,  3 },  {  1,  4 },  {  2,  5 },  { 3, 5 } });
            Assert.IsTrue(grid[0,2].IsAlive);
            Assert.IsTrue(grid[0, 3].IsAlive);
            Assert.IsTrue(grid[1, 4].IsAlive);
            Assert.IsTrue(grid[2, 5].IsAlive);
            Assert.IsTrue(grid[3, 5].IsAlive);
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentOutOfRangeException))]
        public void WhenInitializingIncorrectlyRowCellGridThenExceptionShouldBethrown()
        {
            int rows = 20;
            int cols = 10;
            global::Gol.Domain.CellGrid grid = new global::Gol.Domain.CellGrid(rows, cols);
            grid.Intialize(new int[,] { {21,10}});
           
        }
        [TestMethod ]
        [ExpectedException(typeof(ArgumentOutOfRangeException))]
        public void WhenInitializingIncorrectlyColCellGridThenExceptionShouldBethrown()
        {
            int rows = 20;
            int cols = 10;
            global::Gol.Domain.CellGrid grid = new global::Gol.Domain.CellGrid(rows, cols);
            grid.Intialize(new int[,] { { 20, 11 } });

        }
    }
}
